﻿using Harmontronics.DataAccess.IOperate.Business;
using Harmontronics.Model.Common;
using Harmontronics.Model.Dto.Model;
using Harmontronics.Model.Entitys;
using Harmontronics.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Harmontronics.DataAccess.Operate.Business
{
    public class WorkShopOperate : IWorkShopOperate
    {
        private HcDbContext _db { get; set; }
        public WorkShopOperate(HcDbContext db)
        {
            _db = db;
        }
        //查询所有
        public List<WorkShop> GetAllWorkShopList()
        {

            return _db.WorkShops.ToList();
        }

        public WorkShop GetWorkShopById(string id)
        {
            return _db.WorkShops.SingleOrDefault(i => i.WorkShopId == id);
        }

        public List<WorkShop> GetWorkShopByIdList(List<string> ids)
        {
            return _db.WorkShops.Where(i => ids.Contains(i.WorkShopId)).ToList();
        }

        public void AddWorkShop(WorkShop entity)
        {
            _db.WorkShops.Add(entity);
        }

        public void UpdateWorkShop(WorkShop entity)
        {
            _db.WorkShops.Update(entity);
        }

        public void DeleteWorkShop(WorkShop entity)
        {
            _db.WorkShops.Remove(entity);
        }

        public void BatchDelWorkShop(List<WorkShop> entity)
        {
            _db.WorkShops.RemoveRange(entity);

        }
    }
}
